"use strict";
cc._RF.push(module, 'b5fe5qsVWxJXq1OyvF/pmV1', 'Pool');
// script/Pool.js

"use strict";

/**
 * 水
 */
cc.Class({
    extends: cc.Component,

    properties: {
        player: cc.Node
    },

    // onLoad () {},

    start: function start() {
        this.playerRig = this.player.getComponent(cc.RigidBody);
        this.playerPhysicsBox = this.player.getComponent(cc.PhysicsBoxCollider);
    },


    onEndContact: function onEndContact(contact, selfCollider, otherCollider) {
        //水里
        if (this.player.model === "Land" && otherCollider.tag === 88) {
            this.player.model = "Sea";
            this.player.prop = "Motionless";
            this.player.anchorY = 0.5;

            this.playerPhysicsBox.offset.y = 0;
            this.playerPhysicsBox.apply();
            this.player.getComponent(cc.Animation).stop();
            this.player.getComponent(cc.Animation).play("heroDive");
            this.playerRig.fixedRotation = false;
            this.playerRig._b2Body.m_linearVelocity.x = 0;
            this.playerRig._b2Body.m_linearVelocity.y = 0;
            this.playerRig._b2Body.m_gravityScale = 0;
        } else if (this.player.model === "Sea" && otherCollider.tag === 88) {
            //陆地
            this.player.model = "Land";
            this.player.prop = "Jump";
            this.player.anchorY = 0;
            this.playerPhysicsBox.offset.y = 27;
            this.playerPhysicsBox.apply();
            this.playerRig._b2Body.m_linearVelocity.y = 8;
            this.playerRig._b2Body.m_gravityScale = 3;
            this.playerRig.fixedRotation = true;
        }
    }
});

cc._RF.pop();